<template>
	<RightBox>
		<div class="right">
			<Message :info="tyMsgList" />
			<br /><br />
			<Message :info="nbMsgList" />
		</div>
	</RightBox>
</template>
<script lang="ts" setup>
	import { ref, onMounted } from 'vue'
	import Message from './Message.vue'
	import { getMyMessage } from '@/api/train'

  const tyMsgList = ref<any>({
    msgType: '通用通知',
    createUserAccount: '',
    msgContent: ""
  });
  const nbMsgList = ref<any>({
    msgType: '部门内部通知',
    createUserAccount: '',
    msgContent: ""
  });
	const msgList = ref([])

	onMounted(async () => {
		const userinfo = localStorage.getItem('userinfo');
    if (!userinfo) return;
		let params = {
			pageSize: 10,
			pageNum: 1,
      userId: JSON.parse(userinfo).userId,
		}
    tyMsgList.value.createUserAccount = JSON.parse(userinfo).username;
    nbMsgList.value.createUserAccount = JSON.parse(userinfo).username;
		await getMyMessage(params).then(msgRes => {
      // 1：国铁通知，2：地铁通知，3：通用通知，4：部门内部通知
			tyMsgList.value.msgContent = msgRes.data.records.filter((mItem: any) => {
				return mItem.msgType == "3"
			})?.[0]?.msg ?? "";
      nbMsgList.value.msgContent = msgRes.data.records.filter((mItem: any) => {
				return mItem.msgType == "4"
			})?.[0]?.msg ?? "";
		})
	})
</script>

<style lang="scss" scoped>
	.right {
		margin-top: 106px;
	}
</style>
